package org.qpcr.community.project.enums;

import lombok.Getter;
import org.qpcr.community.project.model.entity.DataAnalysisExperimentalRecordsEntity;

import java.util.function.Function;

@Getter
public enum DataAnalysisDashboardXField {
    ITEM("item","检测项","String", DataAnalysisExperimentalRecordsEntity::getItem),
    NAME("name","项目名称","String", DataAnalysisExperimentalRecordsEntity::getName),
    RECEIVE_TIME("receive_time","检测时间","String",DataAnalysisExperimentalRecordsEntity::getReceiveTime),
    MODULE_CODE("module_code","模块编号","String",DataAnalysisExperimentalRecordsEntity::getModuleCode),
    REAGENT_NUMBER("reagent_number","试剂编号","String",DataAnalysisExperimentalRecordsEntity::getReagentNumber),
    CREATOR_NAME("creator_name","创建人","String",DataAnalysisExperimentalRecordsEntity::getCreatorName),
    FAM("fam","FAM","Double",DataAnalysisExperimentalRecordsEntity::getFam),
    ROX("rox","ROX","Double",DataAnalysisExperimentalRecordsEntity::getRox),
    VIC("vic","VIC","Double",DataAnalysisExperimentalRecordsEntity::getVic),
    CY5("cy5","CY5","Double",DataAnalysisExperimentalRecordsEntity::getCy5),
    TM_FAM("tm_fam","TM_FAM","Double",DataAnalysisExperimentalRecordsEntity::getTmFam),
    TM_ROX("tm_rox","TM_ROX","Double",DataAnalysisExperimentalRecordsEntity::getTmRox),
    TM_VIC("tm_vic","TM_VIC","Double",DataAnalysisExperimentalRecordsEntity::getTmVic),
    TM_CY5("tm_cy5","TM_CY5","Double",DataAnalysisExperimentalRecordsEntity::getTmCy5),
    AMPLIFICATION_CURVES("amplification_curves","扩增曲线数据","Double",DataAnalysisExperimentalRecordsEntity::getAc),
    YIN_YANG_TCM("yin_yang_tcm","阴阳性数据","String",null),;

    private final String field;

    private final String name;

    private final String dataType;

    private final Function<DataAnalysisExperimentalRecordsEntity, Object> apply;

    DataAnalysisDashboardXField(String field,String name,String dataType, Function<DataAnalysisExperimentalRecordsEntity, Object> apply) {
        this.field = field;
        this.name = name;
        this.dataType = dataType;
        this.apply = apply;
    }


    public Boolean isYinYangTcm() {
        return this.getField().equals(YIN_YANG_TCM.getField());
    }

    public static Function<DataAnalysisExperimentalRecordsEntity, Object> getApplyField(String field) {
        for (DataAnalysisDashboardXField value : DataAnalysisDashboardXField.values()) {
            if (value.getField().equals(field)) {
                return value.apply;
            }
        }
        return null;
    }

    public static DataAnalysisDashboardXField getByField(String field) {
        for (DataAnalysisDashboardXField value : DataAnalysisDashboardXField.values()) {
            if (value.getField().equals(field)) {
                return value;
            }
        }
        return null;
    }
}
